#include "rna.h"

//fazer uma funcao para inicializar os padroes

void on_start(){
	int seed = 13111900;
	srand(seed);
	int zero[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
	int um[] = {0,0,1,0,0,
				0,1,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				1,1,1,1,1};
	int dois[] = {0,1,1,1,0,
				 0,1,0,1,0,
				 0,0,0,1,0,
				 0,0,1,0,0,
				 0,1,0,0,0,
				 1,1,1,1,1};
	int tres[] = {0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,1,1,1,1};
	int quatro[] = {1,0,0,1,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,0,1,0,
					0,0,0,1,0};
	int cinco[] = {0,1,1,1,1,
					0,1,0,0,0,
					0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,1,1,1,1};
	memcpy(padroes[0].xs+sizeof(int), zero, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes[1].xs+sizeof(int), um, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes[2].xs+sizeof(int), dois, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes[3].xs+sizeof(int), tres, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes[4].xs+sizeof(int), quatro, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes[5].xs+sizeof(int), cinco, (NUM_ENTRADAS - 1) * sizeof(int));
	//respostas neuronios
	int tmp[NUM_PADROES][NUM_PADROES] = {
    								{1,0,0,0,0,0},
									{0,1,0,0,0,0},
									{0,0,1,0,0,0},
									{0,0,0,1,0,0},
									{0,0,0,0,1,0},
									{0,0,0,0,0,1}
									};
	memcpy(respostas_padroes[0],tmp[0],6*sizeof(int));
	memcpy(respostas_padroes[1],tmp[1],6*sizeof(int));
	memcpy(respostas_padroes[2],tmp[2],6*sizeof(int));
	memcpy(respostas_padroes[3],tmp[3],6*sizeof(int));
	memcpy(respostas_padroes[4],tmp[4],6*sizeof(int));
	memcpy(respostas_padroes[5],tmp[5],6*sizeof(int));
	//padrões distorcidos 0 e 1
	int zero_um[] = {0,1,1,1,0,
				  0,1,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
	int zero_dois[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  0,1,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
    int zero_tres[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  0,1,0,0,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
    int zero_quatro[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  0,1,0,0,1,
				  0,1,1,1,0};
    int zero_cinco[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,1,1,1,0};
    int zero_seis[] = {0,1,1,1,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
    int zero_sete[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
    int zero_oito[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  1,0,1,0,1,
				  1,0,1,0,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
    int zero_nove[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  1,0,1,0,1,
				  1,1,0,1,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
    int zero_dez[] = {0,1,1,1,0,
				  1,0,0,0,1,
				  1,0,0,0,1,
				  1,0,0,1,1,
				  1,0,0,0,1,
				  0,1,1,1,0};
    int um_um[] = {0,0,1,0,0,
				0,1,1,0,0,
				1,0,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				1,1,1,1,1};
    int um_dois[] = {0,0,1,0,0,
				0,1,1,0,0,
				0,0,0,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				1,1,1,1,1};
    int um_tres[] = {0,0,1,0,0,
				0,1,1,0,0,
				0,0,0,0,0,
				0,0,0,0,0,
				0,0,0,0,0,
				1,1,1,1,1};
    int um_quatro[] = {0,0,1,0,0,
				0,1,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				1,1,0,1,1};
    int um_cinco[] = {0,0,1,0,0,
				0,1,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				1,1,1,1,0};
    int um_seis[] = {0,0,1,0,0,
				0,1,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				0,1,1,1,0,
				1,1,1,1,1};
    int um_sete[] = {0,0,1,1,0,
				0,1,1,1,0,
				0,0,1,1,0,
				0,0,1,1,0,
				0,0,1,1,0,
				1,1,1,1,1};
    int um_oito[] = {0,0,1,0,0,
				0,1,1,0,0,
				1,1,1,0,0,
				0,0,1,0,0,
				0,1,1,0,0,
				1,1,1,1,1};
    int um_nove[] = {0,0,1,0,0,
				0,1,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				0,0,1,0,0,
				0,0,0,0,0};
    int um_dez[] = {0,1,1,0,0,
				0,1,1,0,0,
				0,1,1,0,0,
				0,0,1,0,0,
				1,0,1,0,1,
				1,1,1,1,1};
    memcpy(padroes_distorcidos[0].xs+sizeof(int), zero_um, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[1].xs+sizeof(int), zero_dois, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[2].xs+sizeof(int), zero_tres, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[3].xs+sizeof(int), zero_quatro, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[4].xs+sizeof(int), zero_cinco, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[5].xs+sizeof(int), zero_seis, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[6].xs+sizeof(int), zero_sete, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[7].xs+sizeof(int), zero_oito, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[8].xs+sizeof(int), zero_nove, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[9].xs+sizeof(int), zero_dez, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[10].xs+sizeof(int), um_um, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[11].xs+sizeof(int), um_dois, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[12].xs+sizeof(int), um_tres, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[13].xs+sizeof(int), um_quatro, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[14].xs+sizeof(int), um_cinco, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[15].xs+sizeof(int), um_seis, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[16].xs+sizeof(int), um_sete, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[17].xs+sizeof(int), um_oito, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[18].xs+sizeof(int), um_nove, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[19].xs+sizeof(int), um_dez, (NUM_ENTRADAS - 1) * sizeof(int));
	//padroes distorcidos dois e tres
	int dois_um[] = {0,1,1,1,0,
    				 0,1,0,1,0,
	    			 0,0,0,1,0,
	    			 0,0,1,0,0,
	    			 1,1,1,1,1,
	    			 1,1,1,1,1};
	int dois_dois[] = {0,1,1,1,0,
    				 0,1,0,1,0,
	    			 0,0,0,1,0,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 1,1,1,1,1};
	int dois_tres[] = {0,1,1,1,0,
    				 0,1,0,1,0,
	    			 0,0,0,1,0,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 0,0,0,0,0};
	int dois_quatro[] = {0,0,0,0,0,
    				 0,1,1,1,0,
	    			 0,0,0,1,0,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 1,1,1,1,1};
	int dois_cinco[] = {0,1,1,0,0,
    				 0,1,1,0,0,
	    			 0,0,1,0,0,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 1,1,1,1,1};
	int dois_seis[] = {0,1,1,1,0,
    				 0,1,0,1,0,
	    			 0,0,0,1,0,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 0,1,1,1,0};
	int dois_sete[] = {0,0,1,0,0,
    				 0,1,0,1,0,
	    			 0,0,0,1,0,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 1,1,1,1,1};
	int dois_oito[] = {1,1,1,1,0,
    				 1,1,0,1,0,
	    			 0,0,0,1,0,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 1,1,1,1,1};
	int dois_nove[] = {0,1,1,1,1,
    				 0,1,0,0,1,
	    			 0,0,0,1,1,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 1,1,1,1,1};
	int dois_dez[] = {0,1,1,1,0,
    				 0,0,0,1,0,
	    			 0,0,0,1,0,
	    			 0,0,1,0,0,
	    			 0,1,0,0,0,
	    			 1,1,1,1,1};
    int tres_um[] = {0,1,1,1,1,
					0,0,0,1,1,
					0,1,1,1,1,
					0,0,0,1,1,
					0,0,0,1,1,
					0,1,1,1,1};
    int tres_dois[] = {0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1};
    int tres_tres[] = {0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,1,1,1,1};
    int tres_quatro[] = {1,1,1,1,1,
					0,0,0,0,1,
					1,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					1,1,1,1,1};
    int tres_cinco[] = {0,1,1,1,0,
					0,0,0,1,0,
					0,1,1,1,0,
					0,0,0,1,0,
					0,0,0,1,0,
					0,1,1,1,0};
    int tres_seis[] = {0,1,1,1,1,
					0,0,0,1,1,
					0,1,1,1,1,
					0,0,0,1,1,
					0,0,0,1,1,
					0,1,1,1,1};
    int tres_sete[] = {0,1,1,1,1,
					0,0,0,1,1,
					0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,1,1,
					0,1,1,1,1};
    int tres_oito[] = {0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1,
					0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1};
    int tres_nove[] = {0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,0,0,1,1};
    int tres_dez[] = {0,0,0,1,1,
					0,0,0,0,1,
					0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,1,1,1,1};
    memcpy(padroes_distorcidos[20].xs+sizeof(int), dois_um, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[21].xs+sizeof(int), dois_dois, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[22].xs+sizeof(int), dois_tres, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[23].xs+sizeof(int), dois_quatro, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[24].xs+sizeof(int), dois_cinco, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[25].xs+sizeof(int), dois_seis, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[26].xs+sizeof(int), dois_sete, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[27].xs+sizeof(int), dois_oito, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[28].xs+sizeof(int), dois_nove, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[29].xs+sizeof(int), dois_dez, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[30].xs+sizeof(int), tres_um, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[31].xs+sizeof(int), tres_dois, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[32].xs+sizeof(int), tres_tres, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[33].xs+sizeof(int), tres_quatro, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[34].xs+sizeof(int), tres_cinco, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[35].xs+sizeof(int), tres_seis, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[36].xs+sizeof(int), tres_sete, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[37].xs+sizeof(int), tres_oito, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[38].xs+sizeof(int), tres_nove, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[39].xs+sizeof(int), tres_dez, (NUM_ENTRADAS - 1) * sizeof(int));
    //quatro e cinco
    int quatro_um[] = {0,0,0,0,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,0,1,0,
					0,0,0,0,0};
    int quatro_dois[] = {1,0,0,1,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,1,1,0,
					0,0,1,1,0};
    int quatro_tres[] = {1,0,0,0,1,
					1,0,0,0,1,
					1,0,0,0,1,
					1,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1};
    int quatro_quatro[] = {0,1,0,1,0,
					0,1,0,1,0,
					0,1,0,1,0,
					0,1,1,1,0,
					0,0,0,1,0,
					0,0,0,1,0};
    int quatro_cinco[] = {1,0,0,1,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,0,1,0};
    int quatro_seis[] = {1,0,0,1,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,0,1,0,
					0,0,0,1,0};
    int quatro_sete[] = {0,0,1,1,0,
					0,1,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,0,1,0,
					0,0,0,1,0};
    int quatro_oito[] = {1,0,0,1,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,0,1,0,
					0,0,0,0,1};
    int quatro_nove[] = {1,1,1,1,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,0,1,0,
					0,0,0,1,0};
    int quatro_dez[] = {1,0,0,1,0,
					1,0,0,1,0,
					1,0,0,1,0,
					1,1,1,1,0,
					0,0,0,1,0,
					0,0,0,1,0};
    int cinco_um[] = {1,1,1,1,1,
					1,0,0,0,0,
					1,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,1,1,1,1};
    int cinco_dois[] = {0,1,1,1,1,
					0,1,0,0,0,
					0,1,0,0,1,
					0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1};
    int cinco_tres[] = {0,1,1,1,1,
					0,1,0,0,0,
					0,1,1,1,1,
					0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1};
    int cinco_quatro[] = {0,0,1,1,1,
					0,1,0,0,0,
					0,0,1,1,0,
					0,0,0,0,1,
					0,0,0,0,1,
					0,1,1,1,0};
    int cinco_cinco[] = {0,1,1,1,0,
					0,1,0,0,0,
					0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,0,1,1,1};
    int cinco_seis[] = {0,1,1,1,1,
					0,1,0,0,0,
					0,1,1,1,0,
					0,0,0,1,0,
					0,0,0,1,0,
					0,1,1,1,0};
    int cinco_sete[] = {0,1,1,1,1,
					0,1,0,0,0,
					0,1,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,1,1,1,1};
    int cinco_oito[] = {0,1,1,1,1,
					0,1,0,0,0,
					0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1,
					0,0,0,0,0};
    int cinco_nove[] = {0,0,0,0,0,
					0,1,1,1,1,
					0,1,0,0,0,
					0,1,1,1,1,
					0,0,0,0,1,
					0,1,1,1,1};
    int cinco_dez[] = {0,0,1,1,1,
					0,0,1,0,0,
					0,0,1,1,1,
					0,0,0,0,1,
					0,0,0,0,1,
					0,0,1,1,1};
    memcpy(padroes_distorcidos[40].xs+sizeof(int), quatro_um, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[41].xs+sizeof(int), quatro_dois, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[42].xs+sizeof(int), quatro_tres, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[43].xs+sizeof(int), quatro_quatro, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[44].xs+sizeof(int), quatro_cinco, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[45].xs+sizeof(int), quatro_seis, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[46].xs+sizeof(int), quatro_sete, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[47].xs+sizeof(int), quatro_oito, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[48].xs+sizeof(int), quatro_nove, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[49].xs+sizeof(int), quatro_dez, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[50].xs+sizeof(int), cinco_um, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[51].xs+sizeof(int), cinco_dois, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[52].xs+sizeof(int), cinco_tres, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[53].xs+sizeof(int), cinco_quatro, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[54].xs+sizeof(int), cinco_cinco, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[55].xs+sizeof(int), cinco_seis, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[56].xs+sizeof(int), cinco_sete, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[57].xs+sizeof(int), cinco_oito, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[58].xs+sizeof(int), cinco_nove, (NUM_ENTRADAS - 1) * sizeof(int));
	memcpy(padroes_distorcidos[59].xs+sizeof(int), cinco_dez, (NUM_ENTRADAS - 1) * sizeof(int));
}

